---
title: Badge | gluestack-ui | Installation, Usage, and API

description: The badge component lets you quickly and easily add status indicators to your interface for improved usability. They are designed to be attention-grabbing and quickly convey important information.

pageTitle: Badge

pageDescription: The badge component lets you quickly and easily add status indicators to your interface for improved usability. They are designed to be attention-grabbing and quickly convey important information.

showHeader: true
---

import { Meta } from '@storybook/addon-docs';

<Meta title="ui/Components/Data Display/Badge" />

import {
  Badge,
  BadgeText,
  BadgeIcon,
  GlobeIcon,
  Icon,
  Box,
  PuzzleIcon,
} from './Badge';
import {
  SettingsIcon,
  AddIcon,
  PaintBucket,
  Avatar,
  AvatarImage,
  AvatarFallbackText,
} from './Badge';
import { Divider, Image, CheckIcon, Heading } from './Badge';
import { VStack, HStack, Button, ButtonText, BadgeCheckIcon } from './Badge';
import {
  Menu,
  MenuIcon,
  MenuItem,
  MenuItemLabel,
  BadgePlusIcon,
} from './Badge';
import { transformedCode } from '../../../utils';
import {
  AppProvider,
  CodePreview,
  Text,
  Table,
  TableContainer,
  InlineCode,
} from '@gluestack/design-system';
import Wrapper from '../../Wrapper';

This is an illustration of a **Themed Badge** component with default configuration.

<AppProvider>
  <CodePreview
    metaData={{
      code: `
<Badge {...props}>
  <BadgeText>New feature</BadgeText>
  <BadgeIcon as={GlobeIcon} ml='$2' />
</Badge>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Badge,
        BadgeText,
        BadgeIcon,
        GlobeIcon,
      },
      argsType: {
        size: {
          control: 'select',
          options: ['sm', 'md', 'lg'],
          default: 'md',
        },
        variant: {
          control: 'select',
          options: ['solid', 'outline'],
          default: 'solid',
        },
        borderRadius: {
          control: 'select',
          options: [
            '$full',
            '$3xl',
            '$2xl',
            '$xl',
            '$lg',
            '$md',
            '$sm',
            '$xs',
            '$none',
          ],
          default: '$none',
        },
        action: {
          control: 'select',
          options: ['error', 'warning', 'success', 'info', 'muted'],
          default: 'success',
        },
      },
    }}
  />
</AppProvider>

<br />

## API Reference

### Import

To use this component in your project, include the following import statement in your file.

```jsx
import { Badge } from '@gluestack-ui/themed';
```

### Anatomy

The structure provided below can help you identify and understand a badge component's various parts.

```jsx
export default () => (
  <Badge>
    <BadgeText />
    <BadgeIcon />
  </Badge>
);
```

### Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

#### Badge

It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component.

**Descendants Styling Props**
Props to style child components.

<AppProvider>
  <TableContainer>
    <Table>
      <Table.THead>
        <Table.TR>
          <Table.TH>
            <Table.TText>Sx Prop</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Description</Table.TText>
          </Table.TH>
        </Table.TR>
      </Table.THead>
      <Table.TBody>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>_text</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`Prop to style BadgeText Component`}</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>_icon</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`Prop to style BadgeIcon Component`}</Table.TText>
          </Table.TD>
        </Table.TR>
      </Table.TBody>
    </Table>
  </TableContainer>
</AppProvider>

#### BadgeText

It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component.

#### BadgeIcon

Contains all Icon related layout style props and actions. It inherits all the properties of gluestack Style's [AsForwarder](/style/docs/api/as-forwarder) component.

## Themed

The themed version of the component is a pre-styled version of the component, which allows you to quickly integrate the component into your project. The component's design and functionality are fully defined, allowing you to focus on the more important aspects of your project. To know more about Themed Library please visit this [link](https://gluestack.io/ui/docs/core-concepts/themed-library).

### Props

Badge component is created using View component from react-native. It extends all the props supported by [React Native View](https://reactnative.dev/docs/view#props), [utility props](/ui/docs/styling/utility-and-sx-props) and the props mentioned below.

#### Badge

<AppProvider>
  <TableContainer>
    <Table>
      <Table.THead>
        <Table.TR>
          <Table.TH>
            <Table.TText>Name</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Value</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Default</Table.TText>
          </Table.TH>
        </Table.TR>
      </Table.THead>
      <Table.TBody>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>action</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>error | warning | success | info | muted</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>success</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>variant</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>solid | outline</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>solid</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>size</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>sm | md | lg</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>md</Table.TText>
          </Table.TD>
        </Table.TR>
      </Table.TBody>
    </Table>
  </TableContainer>
</AppProvider>

> Note: These props are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these props may not be available.

### Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

#### Badge with Avatar

An example of the Badge component being used with the Avatar component to display badges alongside user avatars for enhanced visual representation or identification.

<AppProvider>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        <VStack space="2xl">
          <HStack space="md">
            <Avatar>
              <AvatarFallbackText>SS</AvatarFallbackText>
              <AvatarImage
                source={{
                  uri: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dXNlcnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=800&q=60',
                }}
              />
            </Avatar>
            <VStack>
            <HStack>
              <Heading size="sm" >Ronald Richards</Heading>
              <Badge  size="sm" variant="solid"  action="success" ml="$1">
                  <BadgeText>Verified</BadgeText>
                  <BadgeIcon as={BadgeCheckIcon} ml="$1"/>
              </Badge>
            </HStack>
            <Text size="sm" >Nursing Assistant</Text>
            </VStack>
          </HStack>
        </VStack>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Avatar,
        AvatarFallbackText,
        AvatarImage,
        Heading,
        Text,
        HStack,
        VStack,
        Badge,
        BadgeText,
        BadgeIcon,
        GlobeIcon,
        BadgeCheckIcon,
      },
      argsType: {},
    }}
  />
</AppProvider>

#### Badge in Menu

A Badge component used with a menu adds a visual indicator, such as a badge, to highlight specific items or provide additional information within the menu, enhancing user interaction and improving the visibility of important elements.

<AppProvider>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
      <Menu
        placement={"top"}
          trigger={({ ...triggerProps }) => {
            return (
              <Button {...triggerProps}>
                <ButtonText>Menu</ButtonText>
              </Button>
            );
          }}
        >
          <MenuItem key="Community" textValue="Community">
            <HStack space="sm" alignItems="center">
              <Icon as={GlobeIcon} size="sm" />
              <Text fontSize="$sm" lineHeight="$md">
                Community
              </Text>
            </HStack>
          </MenuItem>
          <MenuItem key="Plugins" textValue="Plugins">
            <HStack space="sm" alignItems="center">
              <Icon as={PuzzleIcon} size="sm" />
              <Text fontSize="$sm" lineHeight="$md">
                Plugins
              </Text>
            </HStack>
          </MenuItem>
          <MenuItem key="Theme" textValue="Theme">
            <HStack space="sm" alignItems="center">
              <Icon as={PaintBucket} size="sm" />
              <Text fontSize="$sm" lineHeight="$md">
                Theme
              </Text>
               <Badge bg="$backgroundLight600">
                 <BadgeText color="$textLight50">New</BadgeText>
                               </Badge>
            </HStack>
          </MenuItem>
          <MenuItem key="Settings" textValue="Settings">
            <HStack space="sm" alignItems="center">
              <Icon as={SettingsIcon} size="sm" />
              <Text fontSize="$sm" lineHeight="$md">
                Settings
              </Text>
            </HStack>
          </MenuItem>
          <MenuItem key="Add account" textValue="Add account">
            <HStack space="sm" alignItems="center">
              <Icon as={AddIcon} size="sm" />
              <Text fontSize="$sm" lineHeight="$md">
                Add account
              </Text>
            </HStack>
          </MenuItem>
        </Menu>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Button,
        ButtonText,
        Menu,
        MenuIcon,
        MenuItem,
        MenuItemLabel,
        Text,
        Box,
        HStack,
        Icon,
        GlobeIcon,
        PuzzleIcon,
        PaintBucket,
        SettingsIcon,
        AddIcon,
        Badge,
        BadgeText,
        BadgeIcon,
        BadgePlusIcon,
      },
      argsType: {},
    }}
  />
</AppProvider>

### Badge Composition

An example of the Badge component being used with the Composition component, allowing for the display of badges within a composition of other UI elements.

<AppProvider>
  <CodePreview
    showArgsController={false}
    metaData={{
      code: `
       <Box alignItems="center">
      <VStack>
        <Badge  h={22} w={22} bg="$red600" borderRadius="$full"  mb={-14} mr={-14} zIndex={1} variant="solid" alignSelf="flex-end"  >
         <BadgeText color="$white">2</BadgeText>
        </Badge>
        <Button>
         <ButtonText>
          Notifications
        </ButtonText>
        </Button>
      </VStack>
    </Box>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Badge,
        BadgeText,
        BadgeIcon,
        GlobeIcon,
        Box,
        Text,
        HStack,
        VStack,
        Heading,
        Button,
        ButtonText,
      },
      argsType: {},
    }}
  />
</AppProvider>

## Unstyled

All the components in `gluestack-ui` are unstyled by default. To customize your UI using the extendedTheme, please refer to this [link](https://gluestack.io/ui/docs/theme-configuration/customizing-theme/eject-library). The import names of components serve as keys to customize each component.

## Spec Doc

Explore the comprehensive details of the Badge in this document, including its implementation details, checklist, and potential future additions. Dive into the thought process behind the component and gain insights into its development journey.

<iframe
  style={{
    borderRadius: '8px',
    border: ' 1px solid rgba(0, 0, 0, 0.1)',
    aspectRatio: 736 / 585,
  }}
  src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Fproto%2FNcXOxqKbdnGsLQNex3H76u%2F%25C2%25A0%25F0%259F%2593%259Agluestack-UI-handbook%3Ftype%3Ddesign%26node-id%3D6030-27780%26t%3DdmNaOHvCSb4QGYGL-1%26scaling%3Dscale-down%26page-id%3D6030%253A25864%26starting-point-node-id%3D6030%253A27780%26mode%3Ddesign"
  allowFullScreen
/>

<!--

### Advanced

We provide in-depth information on how to customize and extend the component's functionality to meet your needs. Below, we describe how to modify the component to suit your requirements.

### Customizing the Badge

For customizing the Badge, you have to map styled view to Badge You can refer [gluestack.io/style](/style) on how to use styled components.

#### Usage

Default styling of the component can be found in the `components/badge` file. For reference, you can view the [source code](https://github.com/gluestack/gluestack-ui/blob/main/packages/themed/src/components/Badge) of the styled `Badge` component.

```jsx
// import the styles
import { Root, Text, Icon } from '../components/core/badge/styled-components';

// mapping the Badge to root component and compounding the Text and Icon components
const Badge = Root;
BadgeText = Text;
BadgeIcon = Icon;

// Using the badge component
export default () => (
  <Badge>
    <BadgeText></BadgeText>
    <BadgeIcon></BadgeIcon>
  </Badge>
);
```
-->
